/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
import * as $protobuf from "protobufjs/minimal.js";
let $protobuf1 = $protobuf.default;

// Common aliases
const $Reader = $protobuf1.Reader, $Writer = $protobuf1.Writer, $util = $protobuf1.util;

// Exported root namespace
const $root = $protobuf1.roots["default"] || ($protobuf1.roots["default"] = {});

export const pricedetail = $root.pricedetail = (() => {

    /**
     * Properties of a pricedetail.
     * @exports Ipricedetail
     * @interface Ipricedetail
     * @property {number|null} [amount] pricedetail amount
     * @property {number|null} [fl] pricedetail fl
     * @property {string|null} [currency] pricedetail currency
     */

    /**
     * Constructs a new pricedetail.
     * @exports pricedetail
     * @classdesc Represents a pricedetail.
     * @implements Ipricedetail
     * @constructor
     * @param {Ipricedetail=} [properties] Properties to set
     */
    function pricedetail(properties) {
        if (properties)
            for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                if (properties[keys[i]] != null)
                    this[keys[i]] = properties[keys[i]];
    }

    /**
     * pricedetail amount.
     * @member {number} amount
     * @memberof pricedetail
     * @instance
     */
    pricedetail.prototype.amount = 0;

    /**
     * pricedetail fl.
     * @member {number} fl
     * @memberof pricedetail
     * @instance
     */
    pricedetail.prototype.fl = 0;

    /**
     * pricedetail currency.
     * @member {string} currency
     * @memberof pricedetail
     * @instance
     */
    pricedetail.prototype.currency = "";

    /**
     * Creates a new pricedetail instance using the specified properties.
     * @function create
     * @memberof pricedetail
     * @static
     * @param {Ipricedetail=} [properties] Properties to set
     * @returns {pricedetail} pricedetail instance
     */
    pricedetail.create = function create(properties) {
        return new pricedetail(properties);
    };

    /**
     * Encodes the specified pricedetail message. Does not implicitly {@link pricedetail.verify|verify} messages.
     * @function encode
     * @memberof pricedetail
     * @static
     * @param {Ipricedetail} message pricedetail message or plain object to encode
     * @param {$protobuf1.Writer} [writer] Writer to encode to
     * @returns {$protobuf1.Writer} Writer
     */
    pricedetail.encode = function encode(message, writer) {
        if (!writer)
            writer = $Writer.create();
        if (message.amount != null && Object.hasOwnProperty.call(message, "amount"))
            writer.uint32(/* id 1, wireType 0 =*/8).int32(message.amount);
        if (message.fl != null && Object.hasOwnProperty.call(message, "fl"))
            writer.uint32(/* id 2, wireType 0 =*/16).int32(message.fl);
        if (message.currency != null && Object.hasOwnProperty.call(message, "currency"))
            writer.uint32(/* id 3, wireType 2 =*/26).string(message.currency);
        return writer;
    };

    /**
     * Encodes the specified pricedetail message, length delimited. Does not implicitly {@link pricedetail.verify|verify} messages.
     * @function encodeDelimited
     * @memberof pricedetail
     * @static
     * @param {Ipricedetail} message pricedetail message or plain object to encode
     * @param {$protobuf1.Writer} [writer] Writer to encode to
     * @returns {$protobuf1.Writer} Writer
     */
    pricedetail.encodeDelimited = function encodeDelimited(message, writer) {
        return this.encode(message, writer).ldelim();
    };

    /**
     * Decodes a pricedetail message from the specified reader or buffer.
     * @function decode
     * @memberof pricedetail
     * @static
     * @param {$protobuf1.Reader|Uint8Array} reader Reader or buffer to decode from
     * @param {number} [length] Message length if known beforehand
     * @returns {pricedetail} pricedetail
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf1.util.ProtocolError} If required fields are missing
     */
    pricedetail.decode = function decode(reader, length, error) {
        if (!(reader instanceof $Reader))
            reader = $Reader.create(reader);
        let end = length === undefined ? reader.len : reader.pos + length, message = new $root.pricedetail();
        while (reader.pos < end) {
            let tag = reader.uint32();
            if (tag === error)
                break;
            switch (tag >>> 3) {
            case 1: {
                    message.amount = reader.int32();
                    break;
                }
            case 2: {
                    message.fl = reader.int32();
                    break;
                }
            case 3: {
                    message.currency = reader.string();
                    break;
                }
            default:
                reader.skipType(tag & 7);
                break;
            }
        }
        return message;
    };

    /**
     * Decodes a pricedetail message from the specified reader or buffer, length delimited.
     * @function decodeDelimited
     * @memberof pricedetail
     * @static
     * @param {$protobuf1.Reader|Uint8Array} reader Reader or buffer to decode from
     * @returns {pricedetail} pricedetail
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf1.util.ProtocolError} If required fields are missing
     */
    pricedetail.decodeDelimited = function decodeDelimited(reader) {
        if (!(reader instanceof $Reader))
            reader = new $Reader(reader);
        return this.decode(reader, reader.uint32());
    };

    /**
     * Verifies a pricedetail message.
     * @function verify
     * @memberof pricedetail
     * @static
     * @param {Object.<string,*>} message Plain object to verify
     * @returns {string|null} `null` if valid, otherwise the reason why it is not
     */
    pricedetail.verify = function verify(message) {
        if (typeof message !== "object" || message === null)
            return "object expected";
        if (message.amount != null && message.hasOwnProperty("amount"))
            if (!$util.isInteger(message.amount))
                return "amount: integer expected";
        if (message.fl != null && message.hasOwnProperty("fl"))
            if (!$util.isInteger(message.fl))
                return "fl: integer expected";
        if (message.currency != null && message.hasOwnProperty("currency"))
            if (!$util.isString(message.currency))
                return "currency: string expected";
        return null;
    };

    /**
     * Creates a pricedetail message from a plain object. Also converts values to their respective internal types.
     * @function fromObject
     * @memberof pricedetail
     * @static
     * @param {Object.<string,*>} object Plain object
     * @returns {pricedetail} pricedetail
     */
    pricedetail.fromObject = function fromObject(object) {
        if (object instanceof $root.pricedetail)
            return object;
        let message = new $root.pricedetail();
        if (object.amount != null)
            message.amount = object.amount | 0;
        if (object.fl != null)
            message.fl = object.fl | 0;
        if (object.currency != null)
            message.currency = String(object.currency);
        return message;
    };

    /**
     * Creates a plain object from a pricedetail message. Also converts values to other types if specified.
     * @function toObject
     * @memberof pricedetail
     * @static
     * @param {pricedetail} message pricedetail
     * @param {$protobuf1.IConversionOptions} [options] Conversion options
     * @returns {Object.<string,*>} Plain object
     */
    pricedetail.toObject = function toObject(message, options) {
        if (!options)
            options = {};
        let object = {};
        if (options.defaults) {
            object.amount = 0;
            object.fl = 0;
            object.currency = "";
        }
        if (message.amount != null && message.hasOwnProperty("amount"))
            object.amount = message.amount;
        if (message.fl != null && message.hasOwnProperty("fl"))
            object.fl = message.fl;
        if (message.currency != null && message.hasOwnProperty("currency"))
            object.currency = message.currency;
        return object;
    };

    /**
     * Converts this pricedetail to JSON.
     * @function toJSON
     * @memberof pricedetail
     * @instance
     * @returns {Object.<string,*>} JSON object
     */
    pricedetail.prototype.toJSON = function toJSON() {
        return this.constructor.toObject(this, $protobuf1.util.toJSONOptions);
    };

    /**
     * Gets the default type url for pricedetail
     * @function getTypeUrl
     * @memberof pricedetail
     * @static
     * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
     * @returns {string} The default type url
     */
    pricedetail.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
        if (typeUrlPrefix === undefined) {
            typeUrlPrefix = "type.googleapis.com";
        }
        return typeUrlPrefix + "/pricedetail";
    };

    return pricedetail;
})();

export const Price = $root.Price = (() => {

    /**
     * Properties of a Price.
     * @exports IPrice
     * @interface IPrice
     * @property {string|null} [k1] Price k1
     * @property {string|null} [k2] Price k2
     * @property {Ipricedetail|null} [detail] Price detail
     * @property {number|null} [k7] Price k7
     * @property {Long|null} [price] Price price
     */

    /**
     * Constructs a new Price.
     * @exports Price
     * @classdesc Represents a Price.
     * @implements IPrice
     * @constructor
     * @param {IPrice=} [properties] Properties to set
     */
    function Price(properties) {
        if (properties)
            for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                if (properties[keys[i]] != null)
                    this[keys[i]] = properties[keys[i]];
    }

    /**
     * Price k1.
     * @member {string} k1
     * @memberof Price
     * @instance
     */
    Price.prototype.k1 = "";

    /**
     * Price k2.
     * @member {string} k2
     * @memberof Price
     * @instance
     */
    Price.prototype.k2 = "";

    /**
     * Price detail.
     * @member {Ipricedetail|null|undefined} detail
     * @memberof Price
     * @instance
     */
    Price.prototype.detail = null;

    /**
     * Price k7.
     * @member {number} k7
     * @memberof Price
     * @instance
     */
    Price.prototype.k7 = 0;

    /**
     * Price price.
     * @member {Long} price
     * @memberof Price
     * @instance
     */
    Price.prototype.price = $util.Long ? $util.Long.fromBits(0,0,true) : 0;

    /**
     * Creates a new Price instance using the specified properties.
     * @function create
     * @memberof Price
     * @static
     * @param {IPrice=} [properties] Properties to set
     * @returns {Price} Price instance
     */
    Price.create = function create(properties) {
        return new Price(properties);
    };

    /**
     * Encodes the specified Price message. Does not implicitly {@link Price.verify|verify} messages.
     * @function encode
     * @memberof Price
     * @static
     * @param {IPrice} message Price message or plain object to encode
     * @param {$protobuf1.Writer} [writer] Writer to encode to
     * @returns {$protobuf1.Writer} Writer
     */
    Price.encode = function encode(message, writer) {
        if (!writer)
            writer = $Writer.create();
        if (message.k1 != null && Object.hasOwnProperty.call(message, "k1"))
            writer.uint32(/* id 1, wireType 2 =*/10).string(message.k1);
        if (message.k2 != null && Object.hasOwnProperty.call(message, "k2"))
            writer.uint32(/* id 2, wireType 2 =*/18).string(message.k2);
        if (message.detail != null && Object.hasOwnProperty.call(message, "detail"))
            $root.pricedetail.encode(message.detail, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
        if (message.k7 != null && Object.hasOwnProperty.call(message, "k7"))
            writer.uint32(/* id 7, wireType 0 =*/56).uint32(message.k7);
        if (message.price != null && Object.hasOwnProperty.call(message, "price"))
            writer.uint32(/* id 14, wireType 0 =*/112).uint64(message.price);
        return writer;
    };

    /**
     * Encodes the specified Price message, length delimited. Does not implicitly {@link Price.verify|verify} messages.
     * @function encodeDelimited
     * @memberof Price
     * @static
     * @param {IPrice} message Price message or plain object to encode
     * @param {$protobuf1.Writer} [writer] Writer to encode to
     * @returns {$protobuf1.Writer} Writer
     */
    Price.encodeDelimited = function encodeDelimited(message, writer) {
        return this.encode(message, writer).ldelim();
    };

    /**
     * Decodes a Price message from the specified reader or buffer.
     * @function decode
     * @memberof Price
     * @static
     * @param {$protobuf1.Reader|Uint8Array} reader Reader or buffer to decode from
     * @param {number} [length] Message length if known beforehand
     * @returns {Price} Price
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf1.util.ProtocolError} If required fields are missing
     */
    Price.decode = function decode(reader, length, error) {
        if (!(reader instanceof $Reader))
            reader = $Reader.create(reader);
        let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Price();
        while (reader.pos < end) {
            let tag = reader.uint32();
            if (tag === error)
                break;
            switch (tag >>> 3) {
            case 1: {
                    message.k1 = reader.string();
                    break;
                }
            case 2: {
                    message.k2 = reader.string();
                    break;
                }
            case 3: {
                    message.detail = $root.pricedetail.decode(reader, reader.uint32());
                    break;
                }
            case 7: {
                    message.k7 = reader.uint32();
                    break;
                }
            case 14: {
                    message.price = reader.uint64();
                    break;
                }
            default:
                reader.skipType(tag & 7);
                break;
            }
        }
        return message;
    };

    /**
     * Decodes a Price message from the specified reader or buffer, length delimited.
     * @function decodeDelimited
     * @memberof Price
     * @static
     * @param {$protobuf1.Reader|Uint8Array} reader Reader or buffer to decode from
     * @returns {Price} Price
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf1.util.ProtocolError} If required fields are missing
     */
    Price.decodeDelimited = function decodeDelimited(reader) {
        if (!(reader instanceof $Reader))
            reader = new $Reader(reader);
        return this.decode(reader, reader.uint32());
    };

    /**
     * Verifies a Price message.
     * @function verify
     * @memberof Price
     * @static
     * @param {Object.<string,*>} message Plain object to verify
     * @returns {string|null} `null` if valid, otherwise the reason why it is not
     */
    Price.verify = function verify(message) {
        if (typeof message !== "object" || message === null)
            return "object expected";
        if (message.k1 != null && message.hasOwnProperty("k1"))
            if (!$util.isString(message.k1))
                return "k1: string expected";
        if (message.k2 != null && message.hasOwnProperty("k2"))
            if (!$util.isString(message.k2))
                return "k2: string expected";
        if (message.detail != null && message.hasOwnProperty("detail")) {
            let error = $root.pricedetail.verify(message.detail);
            if (error)
                return "detail." + error;
        }
        if (message.k7 != null && message.hasOwnProperty("k7"))
            if (!$util.isInteger(message.k7))
                return "k7: integer expected";
        if (message.price != null && message.hasOwnProperty("price"))
            if (!$util.isInteger(message.price) && !(message.price && $util.isInteger(message.price.low) && $util.isInteger(message.price.high)))
                return "price: integer|Long expected";
        return null;
    };

    /**
     * Creates a Price message from a plain object. Also converts values to their respective internal types.
     * @function fromObject
     * @memberof Price
     * @static
     * @param {Object.<string,*>} object Plain object
     * @returns {Price} Price
     */
    Price.fromObject = function fromObject(object) {
        if (object instanceof $root.Price)
            return object;
        let message = new $root.Price();
        if (object.k1 != null)
            message.k1 = String(object.k1);
        if (object.k2 != null)
            message.k2 = String(object.k2);
        if (object.detail != null) {
            if (typeof object.detail !== "object")
                throw TypeError(".Price.detail: object expected");
            message.detail = $root.pricedetail.fromObject(object.detail);
        }
        if (object.k7 != null)
            message.k7 = object.k7 >>> 0;
        if (object.price != null)
            if ($util.Long)
                (message.price = $util.Long.fromValue(object.price)).unsigned = true;
            else if (typeof object.price === "string")
                message.price = parseInt(object.price, 10);
            else if (typeof object.price === "number")
                message.price = object.price;
            else if (typeof object.price === "object")
                message.price = new $util.LongBits(object.price.low >>> 0, object.price.high >>> 0).toNumber(true);
        return message;
    };

    /**
     * Creates a plain object from a Price message. Also converts values to other types if specified.
     * @function toObject
     * @memberof Price
     * @static
     * @param {Price} message Price
     * @param {$protobuf1.IConversionOptions} [options] Conversion options
     * @returns {Object.<string,*>} Plain object
     */
    Price.toObject = function toObject(message, options) {
        if (!options)
            options = {};
        let object = {};
        if (options.defaults) {
            object.k1 = "";
            object.k2 = "";
            object.detail = null;
            object.k7 = 0;
            if ($util.Long) {
                let long = new $util.Long(0, 0, true);
                object.price = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
            } else
                object.price = options.longs === String ? "0" : 0;
        }
        if (message.k1 != null && message.hasOwnProperty("k1"))
            object.k1 = message.k1;
        if (message.k2 != null && message.hasOwnProperty("k2"))
            object.k2 = message.k2;
        if (message.detail != null && message.hasOwnProperty("detail"))
            object.detail = $root.pricedetail.toObject(message.detail, options);
        if (message.k7 != null && message.hasOwnProperty("k7"))
            object.k7 = message.k7;
        if (message.price != null && message.hasOwnProperty("price"))
            if (typeof message.price === "number")
                object.price = options.longs === String ? String(message.price) : message.price;
            else
                object.price = options.longs === String ? $util.Long.prototype.toString.call(message.price) : options.longs === Number ? new $util.LongBits(message.price.low >>> 0, message.price.high >>> 0).toNumber(true) : message.price;
        return object;
    };

    /**
     * Converts this Price to JSON.
     * @function toJSON
     * @memberof Price
     * @instance
     * @returns {Object.<string,*>} JSON object
     */
    Price.prototype.toJSON = function toJSON() {
        return this.constructor.toObject(this, $protobuf1.util.toJSONOptions);
    };

    /**
     * Gets the default type url for Price
     * @function getTypeUrl
     * @memberof Price
     * @static
     * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
     * @returns {string} The default type url
     */
    Price.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
        if (typeUrlPrefix === undefined) {
            typeUrlPrefix = "type.googleapis.com";
        }
        return typeUrlPrefix + "/Price";
    };

    return Price;
})();

export { $root as default };
